package common

import (
	"crypto/sha256"
	"encoding/hex"
	"time"
)

const (
	COMMA      = ","
	DateFormat = "200601021504"

	RpcTokenKeyAppKey      = "appKey"
	RpcTokenKeyAppTokenKey = "appToken"
)

func GenerateToken(appKey string, appSecret string) string {
	tool := sha256.New()
	timeStamp := time.Now().Format(DateFormat)
	tokenString := appKey + COMMA + appSecret + timeStamp
	//fmt.Println("sha256的字符串：", tokenString)
	tool.Write([]byte(tokenString))
	return hex.EncodeToString(tool.Sum(nil))
}
